<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div class="app">
        <input type="text" v-model="parentMsg">
        <cyan v-bind:message="parentMsg"></cyan>
        <bbuuttoonn v-bind:elm="elm"></bbuuttoonn>
    </div>
    <script>
        let h2Child = {
            template: '<h2>{{message}}</h2>',
            props: ['message']
        };
        let buttonChild = {
            template: '<button>{{elm}}</button>',
            props: ['elm']
        };
        // 定义全局组件
        /* Vue.component('cyan', {
            template: '<h1>{{message}}</h1>',
            props: ['message']
        }); */
        const vm = new Vue({
            el: '.app',
            data: {
                parentMsg: '父组件内容',
                elm: '这是按钮'
            },
            // 定义局部组件
            components: {
                'cyan': h2Child,
                'bbuuttoonn': buttonChild
            }
        })
    </script>
</body>

</html>